<template>
	<el-dialog title="资源预览对话框" v-model="visible" customClass="customWidth"  destroy-on-close @closed="$emit('closed')">
		<el-form ref="dialogForm" label-width="100px">
			<div v-if="imageType.includes(extName)">
				<el-image :src="appUrl+url"></el-image>
			</div>
			<div v-else-if="videoType.includes(extName)">
				<sc-video :src="appUrl+url" :options="options"></sc-video>
			</div>
			<div v-else-if="audioType.includes(extName)">
				<audio controls ref="audio" v-show="true" :src="appUrl+url"/>
			</div>
			<div v-else>
				<el-empty description="无法预览"></el-empty>
			</div>
		</el-form>
		<template #footer>
			<el-button @click="visible=false" >取 消</el-button>
		</template>
	</el-dialog>
</template>

<script>
import sysConfig from "@/config";
import scVideo from "@/components/scVideo";
export default {
	emits: ['success', 'closed'],
	components: {
		scVideo,
	},
	data() {
		return {
			appUrl:sysConfig.API_URL,
			imageType:sysConfig.IMG_FILE,
			videoType:sysConfig.VIDEO_FILE,
			audioType:sysConfig.AUDIO_FILE,
			options: {
				poster: "",
				pip: true
			},
			visible: false,
			isSaveing: false,
			fileName:"",
			extName:"",
			url:""
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open(){
			this.visible = true;
			return this
		},
		//表单提交方法
		//表单注入数据
		setData(data){
			this.extName = data.extName
			this.fileName = data.fileName
			this.url = data.url;
		}
	}
}
</script>
<style>
.customWidth {
	width: 60%;
}
</style>
